<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	<title>Ready</title>
	<meta http-equiv="Content-language" content="zh-CN" />
	<!-- <script type="text/javascript" src="./jquery-1.8b1.js"></script> -->
	<style type="text/css" media="all">
	</style>
<script type="text/javascript">
//<![CDATA[
//alert($(document.body).selector);
var DOMContentLoaded = function(dom, fn, e, listener){
	var event_name = 'onreadystatechange';
	if(dom.addEventListener){
		if(dom===document){
			event_name = 'DOMContentLoaded';
		}else{
			event_name = 'load';
		}
		dom.removeEventListener(event_name, listener, false);
	}else{
		dom.detachEvent(event_name, listener);
	}
	fn.call(dom, e);
}
var ready = function(dom, fn){
	var callback = function(e){
		e = e || window.event;
		DOMContentLoaded.call(null, dom, fn, e, arguments.callee);
	};
	if(dom.addEventListener){
		if(dom===document){
			dom.addEventListener( "DOMContentLoaded", callback, false );
		}else{
			dom.addEventListener( "load", callback, false );
		}
	}else{
		dom.attachEvent( "onreadystatechange", callback );
	}
};
ready(document, function(e){
	console.log(e['type']);
	var test = document.createElement('img');
	ready(test, function(e){
		console.log(e['type']);
		console.log(this.nodeName.toLowerCase());
	});
	test.src = 'test.png';
	document.getElementById('page').appendChild(test);
});
//]]>
</script>
</head>
<body>
<div id="page">
</div><!-- #page end! -->
</body>
</html>
